const db = require('../../db/sql')

function addDepartment(params,res){
    const { name, parent_id, leader, phone, email } = params;
    // 添加一条部门信息
    const department = {
        name: name,
        parent_id: parent_id,
        leader: leader,
        phone:  phone,
        email:  email
    };
    const sql = 'INSERT INTO department SET ?';
    db.query(sql, department, (err, result) => {
        if (err) {
            console.log(err)
            throw err;
        }
        console.log(`Added department with ID ${result.insertId}`);
        res.status(200).send({
            msg:'添加成功'
        });
    });

}
module.exports =addDepartment
